//
//  UIBarButtonItem+SDExtension.m
//  SuperDoctor
//
//  Created by 李忠 on 7/6/16.
//  Copyright © 2016 SD. All rights reserved.
//

#import "UIBarButtonItem+SDExtension.h"

@implementation UIBarButtonItem (SDExtension)

+ (instancetype) initWithImageStr:(NSString *)str addTarget:(id)target withAction:(SEL)action{
    UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
    [leftBtn setImage:[UIImage imageNamed:str] forState:UIControlStateNormal];
    //修改内边距，让按钮靠近左侧
    leftBtn.contentEdgeInsets = UIEdgeInsetsMake(0, -30, 0, 0);
    [leftBtn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
    return [[UIBarButtonItem alloc] initWithCustomView:leftBtn];
}

@end
